<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <!-- 1、封装一个输入半径求圆的面积的函数 -->
        <script>
            // var num1 = +prompt("请输入半径");
            //     var num2 = Math.PI;
            //     var sum =num1*num1*num2;
            //    document.write("圆的面积为:"+sum);
            
            function yuan(){
                var num1 = +prompt("请输入半径");
                var num2 = Math.PI;
                num2 =num2.toFixed(2);
                var sum =num1*num1*num2;
                document.write("圆的面积为:"+sum);
            }
            yuan();
        </script>
</body>
</html>